/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package io.iec.edp.caf.entity;

import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ApplicationListener;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 获取项目的ip和端口号
 * @author wangyandong
 * @date 2019/9/23 16:54
 * @email wangyandong@inspur.com
 */
public class ServerConfig {
    private ServerProperties properties;

    public ServerConfig(ServerProperties properties){
        this.properties = properties;
    }

    public String getPorts() {
        //http
        int port = this.properties.getPort() != null ? properties.getPort() : 8080;
        return String.format("%s (http)",port);

        //to do https
    }
}
